package item;

import io.Packet;

import java.io.Serializable;

public class BagExtendedChangeItem extends ChangedItem implements Serializable{

	protected Bag bag;
	
	public BagExtendedChangeItem(Bag bag){
		super(ChangedItem.TYPE_COMPLEX,ChangedItem.GRIDCOUNT,false);
		this.bag = bag;
	}
	
	@Override
	public boolean isBroadcast() {
		return false;
	}

	@Override
	public boolean merge(ChangedItem other) {
		if(other instanceof BagExtendedChangeItem){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void makeBroadcastPacket(Packet pt) {

	}

	@Override
	public void pack(Packet pt) {
		pt.put(ChangedItem.TYPE_COMPLEX);
		pt.put(id);
		byte[] bytes = new byte[2];
		bytes[0] = (byte)bag.getId();
		bytes[1] = (byte)bag.getSize();
		pt.put(bytes);
	}

}
